#include<bits/stdc++.h>
using namespace std;
const int N=102;

int n,m;
bool place[N][N];
bool light[N][N];
vector<int> edges[N][N];
const int dr[4] = {0,0,1,-1};
const int dc[4] = {1,-1,0,0};
vector<int> xys;
bool turn[N][N];

int main(){
    scanf("%d%d",&n,&m);
    int r1,r2,c1,c2;
    for(int i=1;i<=m;i++){
        scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
        edges[r1][c1].emplace_back(r2);
        edges[r1][c1].emplace_back(c2);
    }

    memset(place,0,sizeof(place));
    memset(light,0,sizeof(light));
    light[1][1] = true;
    place[1][1] = true;
    xys.emplace_back(1);
    xys.emplace_back(1);

    int dcnt=1;
    memset(turn,0,sizeof(turn));
    while(dcnt>0){
        dcnt = 0;
        int size = xys.size();
        for(int i=0;i<size;i+=2){
            r1 = xys[i];
            c1 = xys[i+1];
            //cout<<'\t'<<r1<<' '<<c1<<endl;
            //开灯
            if(!turn[r1][c1]){
                for(int i=0;i<edges[r1][c1].size();i+=2){
                    r2 = edges[r1][c1][i];
                    c2 = edges[r1][c1][i+1];
                    if(!light[r2][c2]){
                        light[r2][c2] = true;
                        dcnt++;
                    }
                }
                turn[r1][c1] = true;
            }
            //place
            for(int j=0;j<4;j++){
                r2 = r1 + dr[j];
                c2 = c1 + dc[j];
                if(r2<=0||r2>n||c2<=0||c2>n||place[r2][c2]) continue;
                if(light[r2][c2]){
                    //cout<<r2<<' '<<c2<<endl;
                    xys.emplace_back(r2);
                    xys.emplace_back(c2);
                    place[r2][c2] = true;
                    dcnt++;
                }
            }
        }
    }
    int res = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(light[i][j]) res++;
        }
    }
    printf("%d\n",res);
    return 0;
}